package cn.hn.tx.uchblog.service.impl;

import java.util.HashMap;
import java.util.Map;

import cn.hn.comm.ibatis.BaseDAO;
import cn.hn.net.Kit;
import cn.hn.tx.uchblog.model.UchomeBlog;
import cn.hn.tx.uchblog.model.UchomeBlogField;
import cn.hn.tx.uchblog.model.UchomeComment;
import cn.hn.tx.uchblog.service.IUchomeBlogService;

public class UchomeBlogServiceImpl implements IUchomeBlogService {

	final String NAMESPACE = "cn.hn.tx.uchome.dao";
	
	// DAO基类
	private BaseDAO baseDAO;
	
	//发布动态地址
	private String url_publish_feed;
	
	public void insertUchomeComment(UchomeComment uchComment)
	{
		baseDAO.insert(NAMESPACE, "insertUchomeComment", uchComment);
	}
	
	/**
	 * 插入日志和日志分类
	 */
	public void insertUchomeBlogAndField(UchomeBlog blog,UchomeBlogField blogField)
	{
		int iBlogID=insertUchomeBlog(blog);
		blogField.setBlogid(iBlogID);
		insertUchomeBlogField(blogField);
	}
	
	/**
	 * 根据日志ID得到日志
	 */
	public UchomeBlog queryUchomeBlogByBid(Integer blogId)
	{
		return (UchomeBlog)baseDAO.query(NAMESPACE, "queryUchomeBlogByBid", blogId);
	}
	
	/**
	 * 发布日志
	 */
	public void publishUchomeBlog(UchomeBlog blog,UchomeBlogField blogField)
	{
		int iBlogID=insertUchomeBlog(blog);
		blogField.setBlogid(iBlogID);
		insertUchomeBlogField(blogField);

		
		String params="blogid="+iBlogID;

		String url=url_publish_feed+"?"+params;
		
		String back=Kit.httpRequest(url, null, "GET", "GBK");	
	}
	
	
	public Integer insertUchomeBlog(UchomeBlog blog) {
		
		Object obj=baseDAO.insert(NAMESPACE, "insertUchomeBlog", blog);
		
		return (Integer)obj;
	}
	
	
	public void updateUchomeBlog(UchomeBlog blog)
	{
		baseDAO.update(NAMESPACE, "updateUchomeBlog", blog);
	}
	
	
	public Object insertUchomeBlogField(UchomeBlogField blogField)
	{
		return baseDAO.insert(NAMESPACE, "insertUchomeBlogField", blogField);
	}
	
	
	
	
	public String getUrl_publish_feed() {
		return url_publish_feed;
	}

	public void setUrl_publish_feed(String url_publish_feed) {
		this.url_publish_feed = url_publish_feed;
	}

	public BaseDAO getBaseDAO() {
		return baseDAO;
	}

	public void setBaseDAO(BaseDAO baseDAO) {
		this.baseDAO = baseDAO;
	}

}
